<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Registration Form
 *
 * @author Matej Kollar
 */
class Application_Form_Registration extends Zend_Form {

    public function __construct($options = null) {
        parent::__construct($options);

        // Set the method for the display form to POST
        $this->setMethod('post');

        // Add an username element
        $this->addElement('text', 'username', array(
            'label' => 'Your username:',
            'required' => true,            
            'validators' => array(
                new Zend_Validate_Alnum(),
                new Zend_Validate_StringLength(array(
                    'min' => 1,
                    'max' => 15
                )))           
        ));

        // Add an email element
        $this->addElement('text', 'email', array(
            'label' => 'Your email address:',
            'required' => true,
            'filters' => array('StringTrim'),
            'validators' => array('EmailAddress')
        ));

        // Add a password element
        $this->addElement('password', 'password', array(
            'label' => 'Your password:',
            'required' => true,
            'validators' => array(
                new Zend_Validate_Alnum(),
                new Zend_Validate_StringLength(array(
                    'min' => 8,
                    'max' => 15
                )))
        ));

        // Add a password element
        $this->addElement('password', 'cpassword', array(
            'label' => 'Confirm your password:',
            'required' => true,
            'validators' => array(
                new Zend_Validate_Alnum(),
                new Zend_Validate_StringLength(array(
                    'min' => 8,
                    'max' => 15
                )))
        ));

        // Add a captcha
        $this->addElement('captcha', 'captcha', array(
            'label' => 'Please enter the 3 letters displayed below:',
            'required' => true,
            'captcha' => array(
                'captcha' => 'Figlet',
                'wordLen' => 3,
                'timeout' => 300
            )
        ));

        // Add the submit button
        $this->addElement('submit', 'submit', array(
            'ignore' => true,
            'label' => 'Sign What\'s up!',
        ));

        // And finally add some CSRF protection
        $this->addElement('hash', 'csrf', array(
            'ignore' => true,
        ));
    }

}
